TextAid

by Alan Wrigley

TextAid is a multi-tasking application which has been designed to work alongside other applications on the Acorn desktop to provide text handling facilities which are not normally available to those applications. These facilities can be summarised as follows:

  1. Up to 20 text macros may be defined, which can be inserted into any document or writable icon which currently contains the caret, irrespective of the application to which it belongs.
  2. Text may be transferred from any text icon or window title bar anywhere on the desktop, to any document or writable icon owning the caret. It is also possible to transfer small quantities of text from editors into writable icons belonging to other applications.
  3. Both of the above facilities offer an option to delete the text in a writable icon, or a section of marked text in a document, before the new text is inserted.
  4. Printer control codes to control such functions as bold, underline etc. can be inserted into documents created in Edit, SrcEdit and other similar editors which do not normally provide printer control facilities.
  5. CSV and TSV files can be converted to text files and vice versa. Some text files from other systems can also be converted for use on the Acorn.
  6. TextAid can communicate directly with other tasks which have been written to do so, enabling function keys or other sets of keys to be set up to insert macros directly with single key presses.

These facilities will provide an extremely useful addition to the facilities normally available from within text editors, word processors, DTP packages, spreadsheets, databases and any other applications which handle text in any way. The text macro and text transfer facilities (numbers 1 & 2 above) should work with any multi-tasking applications which can accept text input from the keyboard.

Warning: TextAid provides facilities that are normally unavailable under RISC OS. There is a small price to pay for this flexibility: you should not type anything at the keyboard or press any mouse buttons while any insertion process is in operation, as this may affect the operation of TextAid or other applications.

A. GETTING STARTED

Place the program disc into your floppy disc drive and click on the drive icon. You should see a directory display containing the application directory !TextAid. If you have a hard disc, this application can be dragged directly to the required directory on the hard disc. If you do not have a hard disc, we recommend that you make a back-up copy of the TextAid program disc. It is never a good idea to run applications from a master disc, since discs sometimes get corrupted through frequent use.

TextAid is run in the usual way, by double-clicking on its icon in a directory display. The TextAid icon will appear on the icon bar. If you are starting up TextAid from a boot sequence it is possible to arrange for a macro file to be loaded automatically at start-up. Simply add the name of the macro file to the line in your boot file which runs TextAid, separated by a space; for example:

If a file is loaded at start-up in this way, the main TextAid window is not opened automatically. However, you can force this to happen by suffixing the filename in your boot file with a space followed by "-open" or just "-o", for example:

Clicking the Menu button over the icon bar icon will display a menu containing eight options: Info, Open window, Increment 1, Increment 2, Define codes, Hot keys, Warning and Quit.

The Increment 1, Increment 2, Define codes, Hot keys and Warning options will be explained later in this manual.

The Info option displays a standard information box about the program. This includes the version number of the software, which you should quote if ever you need to contact the publisher with queries or problems.

The Quit option terminates TextAid and removes it from the icon bar.

The Open window option leads to a submenu which contains five options: Macros, Codes, Quick macros, Transfer and Convert. Each of these refers to one of TextAid's windows, and apart from Quick macros, each of these windows provides one of the application's facilities. Choosing one of these options will toggle the corresponding window open or closed. If a window is open, that menu option will be ticked. We will now describe each facility in turn.

B. MACROS

Choosing the Macros option from the submenu opens TextAid's main window. This window can also be opened by clicking the Select button over the icon bar icon. On the right-hand side of this window are 20 writable icons, each capable of holding a text string of up to 80 characters. Clicking Select over any of these icons will place the caret into that icon, whereupon text can be typed in. Pressing Return will move the caret into the next writable icon.

To the left of each writable icon is an icon containing a red arrow. Clicking on this with Select will insert the macro from the corresponding writable icon in TextAid's window into the document or icon which currently contains the caret, irrespective of which application it belongs to. For example, if you have an Edit or Impression document open on the desktop, and the caret is in this document, then clicking on one of TextAid's arrow icons will insert the corresponding text into the document at the caret position.

Alternatively you may want to delete some text at the destination before the new text is inserted. If you click on the arrow icon with Adjust, then if the caret is in a writable icon, all the text in that icon will be deleted before the insertion is made. If on the other hand the caret is in a document, any marked text will be deleted first. This will only work for document editors which use the key sequence Ctrl-X to delete marked text. However, this is a fairly standard convention so it should work with many applications. Clearly this action is potentially destructive, so TextAid issues a warning before deleting any text in a document. If you are sure you do not need the warning facility, it can be switched off via the Warning option on the icon bar menu.

This method of inserting macros will not work if the caret is inside a dialogue box, since the box will disappear when you click on the arrow. An alternative method of inserting macros is provided for such circumstances: move the pointer over the required red arrow and press the Alt key. This will insert the macro just as if the arrow had been clicked. There is no option to delete text first if you use this method.

Note that if the caret is not visible on the desktop (i.e. no document has the input focus), TextAid will issue a warning. Similarly, a warning will be given if you try to insert a macro into itself.

Clicking Menu over one of TextAid's windows displays a four-option menu: Info, Open window, Save macros and Clear macros. The Info and Open window options are exactly the same as the options on the icon bar menu, and were described above. The other two options refer to the macros in the main window and are greyed out unless you have opened the menu over that window. Choosing the Clear macros option will erase all the macros currently defined in the window, and empty the writable icons. Since this is a destructive action, a warning will be given before it is carried out to enable you to abort the action if you wish.

LOADING AND SAVING MACROS

The Save macros option from the window menu leads to a standard save box which enables you to save all 20 macros as a text file. A default file name Macros is supplied; you may of course alter this to any name you wish. Dragging the file icon to a directory display will save the file in the usual way. Different sets of macros can be filed for different purposes, allowing you great flexibility when using other packages where you may want to input a number of regularly-used text strings.

You may also load a macro file into TextAid. Any file may be dragged either to the icon bar icon or into the main window. The first 20 lines in any such file will be assumed to be text macros and will be inserted into the 20 writable icons, truncating any lines which are over 80 characters long.

SPECIAL CHARACTERS

Certain special character sequences may be included in a macro string, which will be expanded when the string is inserted into a document. These sequences all start with the vertical bar character (|), which is obtained from the keyboard by pressing Shift-backslash (above the Return key). These sequences are as follows:

||inserts the vertical bar character itself.
|D (or |d)When this is encountered in a macro, the current date is substituted. The format of the date is determined by a system variable TextAid$Date, which is defined in the application's !Run file (see 'Time and date' below). The default format is "(d)d month yyyy" (for example, "3 June 1992" or "25 December 1981").
|F (or |f)inserts a function key code. It should be followed by a digit from 0 to 9 to indicate which function key is required, e.g. |F4. This allows you to build sequences of key presses for dialogue boxes, e.g. find/replace in Edit. Thus the following macro would replace all occurrences of "Window Manager" with "Wimp" in an Edit document:

    |F4Window Manager|NWimp|N|F5|F1

|T (or |t)substitutes the current time, read from the computer's real-time clock. The format for this is determined by another system variable, this time TextAid$Time. This is also defined in the !Run file. The default is "(h)h.mm" in 12-hour format (e.g. "10.51 am" or "2.35 pm").
|N (or |n)inserts a new line, in other words ASCII code 13. Most applications will start a new line on receipt of this code; if you come across an application which does not, it will be necessary to insert the new line manually by pressing Return.
|K (or |k)enables you to insert control codes that simulate other non-character keys being pressed (e.g. cursors, Delete, Copy etc.). |K should be followed by two further characters. The first determines whether the key is simulated on its own or in conjunction with Shift and/or Ctrl, as follows:

    K - key alone
    S - key + Shift
    C - key + Ctrl
    A - key + Shift-Ctrl (i.e. "A" for all)

The second character determines which key is simulated, as follows:

    L - left cursor
    R - right cursor
    U - up cursor
    D - down cursor
    T - tab
    I - insert
    H - home
    E - delete (i.e. "E" for erase)
    C - copy
    P - print

All characters can be in upper or lower case. So for example the sequence |kkc would simulate the pressing of the Copy key on its own, while |kcr would simulate the right cursor key plus Ctrl.

|M (or |m)followed by a 2-digit decimal number can be used to insert another of TextAid's macros. In other words, macro 1 could contain the command |M02. When macro 1 is inserted into a document, it will then contain the text of macro 2 at the point where the command was inserted. This feature allows you to build very long macro strings (i.e. 19 x 80 characters). Macros can only be nested to one level; in other words, in the example given above, if macro 2 itself contained a |M command, this would be ignored.
|I (or |i)inserts an incremented figure, the initial value being taken from the icon bar menu option previously mentioned (see below). Using this facility you could, for example, number paragraphs successively using a macro such as "Paragraph |I". Each time this is inserted, the value will increase, so that you will see "Paragraph 1", Paragraph 2" and so on.

There are in fact two increments which can be used independently of each other. If |I is followed immediately by "1" or "2" (e.g. "Item |I1", "Paragraph |I2") then Increment 1 or Increment 2 will be used respectively; otherwise Increment 1 will be used.

By default, the values for each increment start at 1 and increase by 1 each time a value is inserted by TextAid. However, both the next value to be inserted and the incremental step can be altered from the menu options. Both the Increment 1 and Increment 2 options on the icon bar menu lead to a submenu with two further options: Next and Step. Each of these options leads to a writable icon into which you can type any numeric value. Whatever values are in the writable icons at the time of inserting the increment will be used by the program; for example, if Next = 10 and Step = 5, the next increment to be inserted will be "10", and the following ones will be "15", "20" and so on, unless the values are altered in the meantime from the menu.

QUICK MACROS

There are two ways to access macros quickly without needing to have the main window open on the desktop. Firstly, you can open the Quick macros window from the Open window submenu. This window contains 20 icons labelled 1-20; clicking over any of these will insert the corresponding macro at the caret just as if the arrow icon had been clicked in the main window. Below these icons are four further icons labelled Date, Time, Inc1 and Inc2. Clicking over these inserts the date, the time, increment 1 or increment 2 respectively. As with the icons in the main window, clicking with Select over any icon in the Quick macros window will simply insert the text at the caret position, while clicking with Adjust will delete text first in the same way as described earlier.

Secondly, by switching on the Hot keys option from the icon bar menu, macros can be inserted simply by pressing the Alt key together with a function key (F1 to F10 for macros 1-10, Shift-F1 to Shift-F10 for macros 11-20). There is no option to delete text before insertion if you use this method. When the Hot keys option is on, the menu item will be ticked. If you find that other applications recognise these key sequences and interfere with TextAid, it is better to leave the option switched off.

C. PRINTER CONTROL CODES

Choosing the Codes option from the Open window submenu displays a small window with five printer styles listed on the left-hand side, together with two icons for each labelled On and Off. Above these is an icon labelled Escape, while below is a pair of radio icons labelled Shortcode and Literal.

The purpose of this window is to insert control codes into Edit or other similar editors which will invoke specific printer functions when a text file containing these codes is sent to a printer. Normally it is not possible to print out a document from Edit in this way, unless the actual sequences of codes recognised by the printer are manually inserted into the document. Even this is very difficult to do, since most printer functions make use of the Escape code (ASCII 27), and it is not possible to insert this code into Edit directly, but only by a very long-winded process.

To make use of this facility, you need to understand a little of how your printer works, and also how the RISC OS printer drivers work. In order to tell a printer that you want it to print the next section of text in bold or italic, say, you must send it a precise sequence of control codes. This sequence usually starts with Escape (ASCII 27) - this does not correspond to any printable character (the printable character set starts at 32) and so the printer cannot mistake it for a standard character. The codes which follow the Escape code depend on the function which you wish to set, and these will be described in your printer manual. Most printers which are described as "Epson-compatible" will use the same set of codes for any particular function as any other similar printer.

What TextAid does is to insert into the document either the full literal sequence of codes required by the printer (if the Literal icon is selected), or a single code from the non-printable area of the ASCII set (if Shortcode is selected) which acts as a marker and will be expanded by the printer driver into the full set at the time of printing. The latter is achieved by making use of a facility within the RISC OS printer drivers to intercept any code in the ASCII set and replace it with another code or codes before sending on to the printer.

This is how it works in practice: first of all, the five printer functions provided are user-definable, so if you want to access elite, condensed, double-height or any other printer function, you can customise TextAid to do so. The five functions provided as the default with the package are Bold, Superscript, Italic, Underline and Subscript. To change these to other functions, open the icon bar menu and move to the dialogue box which appears from the Define codes option. On the left-hand side are five writable icons containing the names of the printer functions you wish to use. You may type any names you like into these icons (maximum 10 characters), and these will then be displayed in the Codes window.

Next you must set up the printer codes required by the printer to implement the functions you have chosen. To the right of each of the five icons is a further pair of writable icons, into which you should type the printer's code sequences to switch the function on and off respectively. This takes the form of a string of decimal numbers corresponding to the code sequence, the numbers being separated by commas. For example, your printer manual may say that the code sequence for switching on bold is ESC "E" or CHR$27+CHR$69. What this means is that you must send the ASCII character 27 (Escape) followed by 69 ("E"). To put this sequence into TextAid's dialogue box, the string would therefore read 27,69. Similarly, the sequence to turn off underlining might be ESC "-" 0, which would translate to 27,45,0.

The sequences for producing the five default functions on an Epson-compatible printer are already included. However, even if you stick to the default functions, you may need to alter these sequence strings if you have a non-standard printer.

When you have altered all the settings in the dialogue box to suit your own requirements, click on the OK icon to register them as the current set. Clicking on the Cancel icon will restore the former settings. The set of function names and printer codes can be saved so that they will appear in future as the defaults. To do this, simply click on the Save status icon in the dialogue box.

INSERTING CONTROL CODES

Having done this, you can now use the control code insertion facility from the Codes window. The facility is designed primarily for editors which use the same search/replace routines as Edit. It would be unsuitable and unnecessary to use it with other applications such as word processors, DTP packages etc. which can make use of printer styles, and could cause problems if spurious codes are inserted into documents prepared with these applications. For this reason, it is necessary to tell TextAid explicitly which applications can use this facility. This is done by setting up a text file called AppChoices inside the !TextAid application directory. This is a standard text file, and must contain the names of the applications which can accept the codes which are output from the Codes window. Each application name must be on a separate line, and must be typed exactly as the name appears in the Task Manager's window when the application is installed (to see this, choose the Task display option from the Task Manager's icon bar icon - the symbol on the far right of the icon bar). The complete AppChoices file must not be more than 128 bytes long - this gives enough space for about a dozen or so applications.

An AppChoices file is supplied with TextAid, containing the names Edit, SrcEdit and DeskEdit. These are currently the only editors which use the correct sequence of routines to allow TextAid's control code facility to work, and so you will not normally need to alter this file. The ability to do so is included in case other editors based on the text editing routines used by Edit are released at a later date. It must be stressed that this restriction on application names applies only to the Codes facility, and not the macro facility described above or to the Transfer facility to be described later. In these cases, any application which owns the caret can be the recipient, and it does not have to be specifically named in any way.

Getting back to printer control codes, you can decide whether to insert single codes or full sequences by selecting the appropriate radio icon in the Codes window, as mentioned above. If the Shortcode icon is selected, single codes will be sent; if the Literal icon is selected, the full sequence will be sent (known as a "literal code sequence"). Provided that the application which owns the caret is one of those contained in the AppChoices file, then clicking on one of the On or Off icons will insert the code or codes into the document.

If you are inserting single codes, the code will be one of the set of symbols between ASCII 128 and 140 (e.g. a tick or an arrow). Incidentally, the codes used for bold, italic and underline are the same as those used for these functions in DeskEdit, so if you create a document in, say, Edit or SrcEdit with control codes, that document can later be printed from DeskEdit and the codes will be interpreted correctly.

There is a further icon in the Codes window, labelled Escape. This allows you to include an actual Escape character (ASCII 27) into the document, which is very difficult to do by any other method. You might want to do this if, for example, you want to build printer control sequences directly into your text other than those which are set up in TextAid. The process by which the code is put into the document is a convoluted one, and is not quite instantaneous. You should not perform any other functions until the process is finished and you can see the Escape code in the document (which will be displayed as "[1b]" by Edit, for example).

PRINTER SUPPORT

If you have inserted a literal code sequence into your document, there is usually no need for any further action. Acorn's printer drivers allow you to print text files with all non-printable characters sent straight through to the printer, so your literal sequence will be sent exactly as it stands and the printer will interpret this as a request to turn the required function on or off. To ensure that the printer driver is set up to do this, open the control window (by clicking with Select on the driver's icon bar icon with RISC OS 2, or by choosing Configure from the printer control window menu in RISC OS 3), and select Control codes: standard. Dragging a text file to the printer driver will now result in all characters being sent to the printer.

If you have inserted shortcodes into your document, you need to do a little more work before you see the results on the printer. This is because the printer driver needs to be told how to interpret these codes. Acorn has provided a facility to do this, which differs according to whether you have RISC OS 2 or RISC OS 3. For RISC OS 2, this involves modifying a file called PrDataSrc within the printer driver's application directory. If you load this file into Edit, you will see a section not far from the beginning of the file headed Printable character translations. Underneath this will be one or more lines beginning:

where nnn will be a number less than 256 and string will be a string containing various characters. This tells the printer driver that if code nnn is found in the text, it should be substituted by the string shown (non-printable characters in the string are shown as decimal figures enclosed in angle brackets).

TextAid provides a shortcut for you to do this. Once you have set up all the printer codes you require in the dialogue box, clicking on the Save codes icon will display a save box, initially with a default filename of CharCodes. Dragging the file icon to a directory display will save a file of that name, which will contain a series of lines to be inserted into the PrDataSrc file. Each of these lines will be of the form described above, and nnn in each case will be replaced by the ASCII code of the appropriate shortcode character. All you need to do is to insert these lines into the PrDataSrc file at some point in the Printable character translations section.

This is not quite the end of the story, since the PrDataSrc file itself is not used by the printer driver; instead a compressed version called PrData is used. Instructions for compressing PrDataSrc into PrData are given in the printer driver's help file.

If you have RISC OS 3, things are much simpler. Firstly, load your printer definition file into the PrintEdit application, as explained in the User Guide. Now select the icon marked Edit character mappings, and modify the mappings to suit the functions you wish to access from TextAid. The five functions, Bold, Superscript, Italic, Underline and Subscript, make use of codes 128-132 to switch on, and 136-140 to switch off, in the order given. So if the code sequence for your printer to switch on bold is ESC "E", then you must map character 128 to 27,"E". By looking at the mappings already listed in the window you will see how to do this.

D. TRANSFERRING TEXT

Text can be transferred from text icons or window title bars in one of two ways. The transfer can be made via a TextAid window, allowing you to edit the text before passing it on to its intended destination, or you can transfer the text directly from icon to caret with one key press. The latter method will be described later.

Choosing the Transfer option from the Open window submenu opens a small window containing a writable icon and two further icons labelled Transfer in and Transfer out. To operate the transfer facility, first click over the Transfer in icon. The legend will change to Waiting... to indicate that TextAid is now waiting for you to transfer text. Now click again over the icon or title bar containing the text you wish to transfer, and it will be transferred into the writable icon in the Transfer window. The string may be up to 80 characters long, and will be truncated if it is longer. Note that once you have clicked on Transfer in to activate the process, normal multi-tasking is suspended until the next click of the mouse.

It is also possible to transfer text directly from a document editor into the Transfer window, provided that the editor is able to save a selection of text as a text file. For example, using Edit you can save a marked section of text as a file by choosing the Save option from the Select submenu. If you drag such a file directly into TextAid's Transfer window, the first line of the file, or the first 80 characters if the line is longer than this, will be inserted into the transfer icon. This allows you to transfer text directly from a document into a writable icon belonging to another application via TextAid, which is virtually impossible to do by any other method.

The string in the Transfer window can be edited, or you can transfer it straight out to the caret position by clicking on the Transfer out icon. As before, clicking with Adjust instead of Select enables you to delete text at the destination before the insertion is made. This operates in exactly the same way as described earlier.

For single-key transfer, the keys you press depend on whether you wish to delete text at the destination first. To transfer text without deletion, all you have to do is to position the pointer over the icon or title bar containing the text you wish to transfer, and press the Insert key while holding down Alt. The text will be transferred directly to the caret position, but will not appear in TextAid's Transfer window. To delete text first, just use Alt-Delete instead. The single-key transfer facility makes it extremely easy to move text about on the desktop, by moving the pointer around with one hand and pressing the appropriate keys with the other.

Just as with the macro facility described above, by using either of the transfer methods the text can be inserted into any writable icon or document which contains the caret, irrespective of the application which owns it. This facility has a great many uses; for example, you could transfer long pathnames from Filer window title bars without needing to type the whole name yourself; or you could transfer the results of a calculation from a spreadsheet or calculator into a text document, and so on.

E. FILE CONVERSION

TextAid provides a facility to convert CSV and TSV files to text and vice versa, and to convert some text files prepared on other systems for use on RISC OS. The former can often be useful in allowing you to read more easily a set of textual records output from a database in CSV format, or to prepare a data file in Edit for import into a graph package which accepts CSV files, for example. The latter facility allows you to remove control codes and to convert top-bit-set characters into standard 7-bit ASCII characters, which can make the transfer of files from PC word processors easier.

To use the facility, open the Convert window and select the appropriate radio icon: CSV to text, Text to CSV, TSV to text, Text to TSV or Text to text. Now drag the file to be converted into the Convert window. After a short pause while the data is converted, a standard save box will appear. This will contain the pathname of the original file, so if you wish to save it back with its original name all you need to do is to click on OK or press Return. Alternatively you may amend the name and then save it in the same way, or drag the file icon to a different directory display.

CSV and TSV to/from text

When converting from text, TextAid assumes that a single linefeed is a field separator, while a double linefeed is a line separator. When converting to CSV/TSV, line separators in the output file can be either LF (ASCII 10) or CR-LF (ASCII 13, ASCII 10), depending on the icon selected at the foot of the window. The former should be used for Acorn applications, the latter for export to a PC.

Text and CSV files are saved with the appropriate filetype, and when converting from CSV or text TextAid will only accept files with the correct type (&FFF for text and &DFE for CSV). However, there is no filetype for TSV files, so these files are saved untyped. TSV files are rarely used on the Acorn, and the most likely reason for converting to TSV would be for use on a different system. When converting from TSV, TextAid will accept any filetype, but will then check to see if there are tab characters in the file. If not, it will assume that the file is not TSV and will generate an error.

TEXT TO TEXT

When this icon is selected, two further options appear at the bottom of the window. These are Strip top bit and Strip ctrl codes. These can both be selected or deselected by clicking over the icon. Dragging a file to the window will convert it according to the state of these two icons. In other words, if Strip top bit is selected, all characters above ASCII 128 will have 128 subtracted from their value; if Strip ctrl codes is selected, all characters below ASCII 32 will be removed. End-of-line markers (13, 10 or 13-10) will be converted to ASCII 10 or ASCII 13 plus ASCII 10 depending on the state of the LF and CR-LF icons, as described above. The source file can be of any filetype, so you can convert files which have been transferred from DOS systems, for example.

F. ACCESSING TEXTAID FROM YOUR OWN APPLICATIONS

TextAid's macros can be accessed from within your own applications. This is done by sending TextAid a message via the Wimp messaging system indicating the number of the macro required. This macro will then be inserted into your document. All you have to do is to broadcast a Wimp message using SWI Wimp_SendMessage with an action code of &820C0 at R1+16, and the number of the macro required at R1+20 (it is assumed you are familiar with the use of Wimp_SendMessage). For example, suppose that you would like the function keys F1-F9 to insert one of TextAid's macros 1 to 9 into a document or window belonging to your application. The key codes returned by the Wimp for these keys are &181-&189, so you would include a section of code similar to the following in your procedure which handles key presses:

Provided that TextAid is installed, this will result in the macro which corresponds to the function key pressed being inserted at the caret.

G. TIME AND DATE

As described earlier, TextAid makes use of two system variables to determine the format which is to be used when the date or time are inserted. If you wish to set up your own format you must alter the definitions of the variables in the !Run file. To do this, open up the !TextAid application directory and load the file !Run into Edit. You will see the following two lines:

To understand the format used, and to set your own, you should study the description of system variables in your User Guide, in particular the section on date and time. TextAid uses exactly the same format as described in the User Guide.

H. PROBLEMS

TextAid should work correctly on any Acorn RISC OS computer. However, because of the wide range of possible machine configurations, and also the existence of some other software which is not legally written, problems can occasionally occur with any software package, however well behaved. If you do have problems with TextAid, it would be helpful if you could telephone in the first instance to discuss it with us (there is often someone available in the evenings). A disc returned with a note saying "It doesn't work" can't really help us to solve the problem!

Copyright © Rheingold Enterprises 1993